import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2025-03-30
 * Time: 11:40
 */
public class RedisDemoString {

    public static void main(String[] args) {
        JedisPool jedisPool = new JedisPool("tcp://127.0.0.1:8888");

        /*try (Jedis jedis = jedisPool.getResource()) {
            System.out.println("mget 和 mset的使用");
            jedis.flushAll();

            jedis.mset("key1","11","key2","22", "key3","33");

            List<String> list = jedis.mget("key1","key2","key3");
            System.out.println("value: " + list);

        }*/


        /*try (Jedis jedis = jedisPool.getResource()) {
            System.out.println("getrange 和 setrange的使用");
            jedis.flushAll();

            jedis.set("key1","asasdsadsaasd");

            String value = jedis.getrange("key1",2,5);
            System.out.println("value: " + value);

            jedis.setrange("key1",2,"123");
            String value1 = jedis.get("key1");
            System.out.println("value1: " + value1);
        }*/

        /*try (Jedis jedis = jedisPool.getResource()) {
            System.out.println("append 、incr 和 decr 的使用");
            jedis.flushAll();

            jedis.set("key1","abcdefg");
            jedis.append("key1","123456");
            String value = jedis.get("key1");
            System.out.println("value: " + value);


            jedis.set("key2","100");

            long result = jedis.incr("key2");
            System.out.println("result : " + result);

            String value2 = jedis.get("key2");
            System.out.println("value2: " + value2);

            result = jedis.decr("key2");
            System.out.println("result : " + result);

            value2 = jedis.get("key2");
            System.out.println("value2: " + value2);
        }*/



    }
}
